﻿FIND_PATH(OSG_INCLUDE_DIR osg/Node)

macro(find_osg_library)
  foreach(_var ${ARGN})
    string(TOUPPER ${_var} _varU)
    find_library(${_varU}_LIBRARY_RELEASE NAMES ${_var})
    find_library(${_varU}_LIBRARY_DEBUG NAMES ${_var}d)
    set(${_varU}_LIBRARY ${${_varU}_LIBRARY_RELEASE})
    if(${_varU}_LIBRARY_DEBUG)
      set(${_varU}_LIBRARIES optimized ${${_varU}_LIBRARY_RELEASE} debug ${${_varU}_LIBRARY_DEBUG})
    else()
      set(${_varU}_LIBRARIES ${${_varU}_LIBRARY_RELEASE})
    endif()
    list(APPEND OPENSCENEGRAPH_LIBRARIES ${${_varU}_LIBRARIES})
  endforeach()
endmacro()
find_osg_library(osg osgDB osgFX osgGA osgManipulator osgAnimation osgParticle osgPresentation osgShadow osgSim osgTerrain osgText osgUI osgUtil osgViewer osgVolume osgWidget osgEarth OpenThreads gdal)

if (OSG_INCLUDE_DIR AND OSG_LIBRARY)
  set(OSG_FOUND TRUE)
endif()
